//
//  EndingView.swift
//  FeastBooking
//
//  Created by Imon on 2017/10/14.
//  Copyright © 2017年 Imon. All rights reserved.
//

import UIKit

class EndingView: UIView {
    
    let lSaperator: UIView = {
        let view = UIView()
        view.backgroundColor = saperatorColor
        view.layer.cornerRadius = 20
        view.layer.masksToBounds = true
        return view
    }()
    
    let rSaperator: UIView = {
        let view = UIView()
        view.backgroundColor = saperatorColor
        view.layer.cornerRadius = 20
        view.layer.masksToBounds = true
        return view
    }()
    
    let label: UILabel = {
        let label = UILabel()
        label.textColor = UIColor.gray
        label.textAlignment = .left
        label.font = AppFont(size: 14)
        label.numberOfLines = 0
        label.text = LanguageHelper.getString(key: "NO_MORE_DATE")
        return label
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = lightSaperatorColor
        self.addSubview(lSaperator)
        self.addSubview(rSaperator)
        self.addSubview(label)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        let textMaxSize = CGSize(width: bounds.width, height: bounds.height)
        let labelSize = TextSize.textSize(text: label.text!, font: label.font, maxSize: textMaxSize)
        label.frame = CGRect(x: (self.frame.width - labelSize.width) / 2, y: 5, width: labelSize.width, height: labelSize.height)
        lSaperator.frame = CGRect(x: 0, y: label.frame.origin.y + label.frame.height / 2, width: label.frame.origin.x - 5, height: 1)
        rSaperator.frame = CGRect(x: label.frame.origin.x + label.frame.width + 5, y: label.frame.origin.y + label.frame.height / 2, width: label.frame.origin.x - 5, height: 1)
    }
    
}
